package com.tianya.portal.common.utils;

import com.aspose.cells.SaveFormat;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.aspose.cells.Workbook;

import java.io.*;

public class AsposeCellsUtils {
    private static final Logger log = LogManager.getLogger(AsposeCellsUtils.class);


    /**
     * word转pdf
     * @param inputStream
     * @return
     */
    public static InputStream getCellToPdf(InputStream inputStream) {
        try {
            ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
            Workbook workbook = new Workbook(inputStream);
            workbook.save(outputStream, SaveFormat.PDF);
            byte[] bytes = outputStream.toByteArray();
            InputStream stream = new ByteArrayInputStream(bytes);
            return stream;
        } catch (Exception e) {
            log.error(e.getMessage());
        }
        return null;
    }
}
